#include "../graphmanager/graphmanager.h"

int main() {
	TNodeList NodeList;
	CreateEmptyNodeList(&NodeList);
	NodeList.NNode=3;
	NodeList.node[1]=CreateNode(CharToString("A") , true , true , 0.001);
	NodeList.node[2]=CreateNode(CharToString("B") , true , true , 0.003);
	NodeList.node[3]=CreateNode(CharToString("C") , true , true , 0.002);
	
	TAdjMatrix m;
	int i , j;
	forup(i , 1 , MaxNode - 1) forup(j , 1 , MaxNode - 1) m[i][j] = -1;
	
	m[1][2] = 2;
	m[1][3] = 1;
	m[2][1] = 2;
	m[2][3] = 0.001;
	m[2][4] = 1;
	m[3][1] = 1;
	m[3][2] = 0.001;
	m[3][4] = 5;
	m[4][2] = 1;
	m[4][3] = 5;
	
	TTabstudents tab1;
	TTablectures tab2;
	TTablectures_students tab3;
	
	CreateEmptyTabStudents(&tab1);
	CreateEmptyTabLectures(&tab2);
	CreateEmptyTabRelation(&tab3);
	
	TLectures_Students ah,ahh,ahhh;

	CreateEmptyRelation(&ah);
	CreateEmptyRelation(&ahh);
	CreateEmptyRelation(&ahhh);
	
	ah=CreateRelation(CharToString("13208071") , CharToString("EL2193") , 3 , StringToThnAkademik(CharToString("2009-2010")) , 'A');
	ahh=CreateRelation(CharToString("13508040") , CharToString("EL2195") , 3 , StringToThnAkademik(CharToString("2009-2010")) , 'A');
	ahhh=CreateRelation(CharToString("18108024") , CharToString("MA2071") , 3 , StringToThnAkademik(CharToString("2009-2010")) , 'A');
	
	NodeList.node[1].IsLectures_StudentsExists=true;
	NodeList.node[2].IsLectures_StudentsExists=true;
	
	NodeList.node[1].lectures_students.NRelation=1;
	NodeList.node[2].lectures_students.NRelation=2;
	NodeList.node[1].lectures_students.t[1]=ah;
	NodeList.node[2].lectures_students.t[1]=ahh;
	NodeList.node[2].lectures_students.t[2]=ahhh;
	
	string s[10];
	s[1]=CharToString("*");
	//s[2]=CharToString("Nama");
	//s[3]=CharToString("IPK");
	
	string cond[3];
	cond[0]=CharToString("NIM");
	cond[1]=CharToString("!=");
	cond[2]=CharToString("LALA");
	
	RetrieveLectures_StudentsRecord(&m , &NodeList , s , 1 , cond , 3 , true , NodeList.node[1]);
	ah=CreateRelation(CharToString("18108006") , CharToString("EL2193") , 3 , StringToThnAkademik(CharToString("2009-2010")) , 'A');
	
	InsertLectures_StudentsRecord(&m , &NodeList.node[1] , &NodeList , ah , NodeList.node[1]);
	RetrieveLectures_StudentsRecord(&m , &NodeList , s , 1 , cond , 3 , false , NodeList.node[1]);
	
	cond[0]=CharToString("NIM");
	cond[1]=CharToString("=");
	cond[2]=CharToString("13208071");
	
	ahh=CreateRelation(CharToString("-") , CharToString("IF2030") , 4 , StringToThnAkademik(CharToString("2009-2010")) , 'B');
	UpdateLectures_StudentsTable(&m , &NodeList , ahh , cond , 3 , NodeList.node[1]);
	cond[0]=CharToString("-");
	RetrieveLectures_StudentsRecord(&m , &NodeList , s , 1 , cond , 3 , false , NodeList.node[1]);
	
	cond[0]=CharToString("NIM");
	cond[1]=CharToString("=");
	cond[2]=CharToString("13208071");
	DeleteLectures_StudentsRecord(&m , &NodeList , cond , 3 , NodeList.node[1]);
	
	cond[0]=CharToString("-");
	RetrieveLectures_StudentsRecord(&m , &NodeList , s , 1 , cond , 3 , true , NodeList.node[1]);
	
	
	
	return 0;
}
